﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EMS20.UI.PageMaster
{

    using EMS20.BusinessLogicLayer;
    using EMS20.Entity;

    public partial class Site1 : System.Web.UI.MasterPage
    {
        //生成左菜单的字符串
        protected System.Text.StringBuilder sb = new System.Text.StringBuilder(200);

        protected void Page_Load(object sender, EventArgs e)
        {
            //得到左边菜单列表
            List<MenusEntity> list = Menus_BLLSub.Get_MenusAll() as List<MenusEntity>;

            //判断当前数据是否是顶级菜单，并且生成顶级菜单
            for (int i = 0; i < list.Count; i++)
            {
                sb.Append("<li class='level1'><a href='" + list[i].m_url + "'>" + list[i].m_name + "</a></li>");
                sb.Append("<li><ul>");
                //生成顶级菜单下面的子菜单
                foreach (MenusEntity item in list)
                {
                    if (item.m_parent_mid == list[i].m_id)
                    {
                        sb.Append("<li class='level2'><a href='" + item.m_url + "'>>>" + item.m_name + "</a></li>");
                    }
                }
                sb.Append("</ul></li>");
            }
        }
    }
}